/*! ******************************************************************************
 *
 * Pentaho
 *
 * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
 *
 * Use of this software is governed by the Business Source License included
 * in the LICENSE.TXT file.
 *
 * Change Date: 2029-07-20
 ******************************************************************************/


package org.pentaho.runtime.test.test.impl;

import org.pentaho.runtime.test.RuntimeTest;
import org.pentaho.runtime.test.result.RuntimeTestResult;
import org.pentaho.runtime.test.result.RuntimeTestResultEntry;
import org.pentaho.runtime.test.result.RuntimeTestResultSummary;
import org.pentaho.runtime.test.result.org.pentaho.runtime.test.result.impl.RuntimeTestResultSummaryImpl;

import java.util.List;

/**
 * Created by bryan on 8/12/15.
 */
public class RuntimeTestResultImpl implements RuntimeTestResult {
  private final RuntimeTest runtimeTest;
  private final boolean isDone;
  private final RuntimeTestResultSummary runtimeTestResultSummary;
  private final long timeTaken;

  public RuntimeTestResultImpl( RuntimeTest runtimeTest, boolean isDone,
                                RuntimeTestResultSummary runtimeTestResultSummary,
                                long timeTaken ) {
    this.runtimeTest = runtimeTest;
    this.isDone = isDone;
    this.runtimeTestResultSummary =
      runtimeTestResultSummary == null ? new RuntimeTestResultSummaryImpl( null ) : runtimeTestResultSummary;
    this.timeTaken = timeTaken;
  }

  @Override public RuntimeTest getRuntimeTest() {
    return runtimeTest;
  }

  @Override public boolean isDone() {
    return isDone;
  }

  @Override public long getTimeTaken() {
    return timeTaken;
  }

  @Override public RuntimeTestResultEntry getOverallStatusEntry() {
    return runtimeTestResultSummary.getOverallStatusEntry();
  }

  @Override public List<RuntimeTestResultEntry> getRuntimeTestResultEntries() {
    return runtimeTestResultSummary.getRuntimeTestResultEntries();
  }

  //OperatorWrap isn't helpful for autogenerated methods
  //CHECKSTYLE:OperatorWrap:OFF

  @Override public String toString() {
    return "RuntimeTestResultImpl{" +
      "runtimeTest=" + runtimeTest +
      ", isDone=" + isDone +
      ", runtimeTestResultSummary=" + runtimeTestResultSummary +
      ", timeTaken=" + timeTaken +
      '}';
  }

  //CHECKSTYLE:OperatorWrap:ON
}
